package beans;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

import modelo.AreaTematica;

import dao.AreaTematicaDao;
import excepciones.DaoException;


@ManagedBean //(name = "LoginBean")
@SessionScoped
public class ListAreasTematicasBean {
	
	@ManagedProperty(value="#{loginBean}")
	private LoginBean loginBean;	
	
	private Long selected;	
	private List<AreaTematica> areas_tematicas;
	
	
	@PostConstruct
	public void init(){		
			AreaTematicaDao atDao = new AreaTematicaDao();
			try {
				this.setAreas_tematicas(atDao.getTodasAreas());
			} catch (DaoException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

	public LoginBean getLoginBean() {
		return loginBean;
	}
	public void setLoginBean(LoginBean loginBean) {
		this.loginBean = loginBean;
	}
	
	public String editarAreaTematica()
	{ 		
		return "irEditarAreaTematica";
	}
	
	public String nuevo(){		
		
		setSelected(null);
		return "irEditarAreaTematica";
	}

	public String volver(){
		System.out.println("irIndex"+this.getLoginBean().getObjPerfil().getNombre());
		return "irIndex"+this.getLoginBean().getObjPerfil().getNombre();
	}
	

	public Long getSelected() {
		return selected;
	}

	public void setSelected(Long selected) {
		this.selected = selected;
	}

	public List<AreaTematica> getAreas_tematicas() {
		return areas_tematicas;
	}

	public void setAreas_tematicas(List<AreaTematica> areas_tematicas) {
		this.areas_tematicas = areas_tematicas;
	}	

	
	
}